local ma__suqiu = fk.CreateSkill {
  name = "ma__suqiu",
  tags = { Skill.Combo },
}

Fk:loadTranslationTable{
  ["ma__suqiu"] = "肃秋",
  [":ma__suqiu"] = "连招技（装备牌+【杀】），你可以弃置至多X名相邻的角色各一张牌（X为目标角色的体力值），然后你获得其中一张牌。",

  ["#ma__suqiu-use"] = "肃秋：你可以将至多%arg张手牌当【杀】使用（伤害基数为你选择的牌数）",

  ["$ma__suqiu1"] = "颅献白骨观，血祭黄沙场！",
  ["$ma__suqiu2"] = "拥酒炙胡马，北虏复唱匈奴歌！",
}

ma__suqiu:addEffect(fk.CardUseFinished, {
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(ma__suqiu.name) and
      data.card.sub_type == Card.SubtypeWeapon and
      data.extra_data and data.extra_data.combo_skill and data.extra_data.combo_skill[ma__suqiu.name] and
      table.contains(player:getEquipments(Card.SubtypeWeapon), data.card.id) and
      #player:getHandlyIds() > 0
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local n = Fk:translate(data.card.name, "zh_CN"):len()
    local use = room:askToUseVirtualCard(player, {
      name = "slash",
      skill_name = ma__suqiu.name,
      prompt = "#ma__suqiu-use:::"..n,
      cancelable = true,
      extra_data = {
        bypass_times = true,
        extraUse = true,
      },
      card_filter = {
        n = { 1, n },
        cards = player:getHandlyIds(),
      },
      skip = true,
    })
    if use then
      event:setCostData(self, {extra_data = use})
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local use = event:getCostData(self).extra_data
    use.additionalDamage = #Card:getIdList(use.card) - 1
    room:useCard(use)
  end,
})
ma__suqiu:addEffect(fk.AfterCardUseDeclared, {
  can_refresh = function (self, event, target, player, data)
    return target == player and player:hasSkill(ma__suqiu.name, true)
  end,
  on_refresh = function (self, event, target, player, data)
    local room = player.room
    if data.card.sub_type == Card.SubtypeWeapon then
      room.logic:getEventsByRule(GameEvent.UseCard, 1, function (e)
        if e ~= room.logic:getCurrentEvent() then
          local use = e.data
          if use.from == player then
            if
              not use.card.is_passive and
              not use.card.multiple_targets and
              not table.contains(use.card.skillNames, ma__suqiu.name)
            then
              data.extra_data = data.extra_data or {}
              data.extra_data.combo_skill = data.extra_data.combo_skill or {}
              data.extra_data.combo_skill[ma__suqiu.name] = true
            else
              room:setPlayerMark(player, ma__suqiu.name, 0)
            end
            return true
          end
        end
      end, 1)
      if player:getMark(ma__suqiu.name) == 0 and
        not data.card.is_passive and not data.card.multiple_targets then
        room:setPlayerMark(player, ma__suqiu.name, 1)
      end
    else
      room:setPlayerMark(player, ma__suqiu.name, 0)
    end
  end,
})

return ma__suqiu
